package com.ruoyi.forApp.controller;

import com.ruoyi.forApp.domain.NewsForApp;
import com.ruoyi.forApp.service.INewsServiceForApp;
import com.ruoyi.framework.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

//安卓端新闻页数据

@Controller
public class NewsControllerForApp extends BaseController {

    @Autowired
    private INewsServiceForApp newsServiceForApp;

    @PostMapping("/getNews")
    @ResponseBody
    public Map<String,Object> getNews(Long userId){
        Map<String,Object> map=new HashMap<>();
        if (userId>-1){
            List<NewsForApp> newsForApps=newsServiceForApp.selectNewsByUserId(userId);
            map.put("newsList",newsForApps);
            map.put("success",true);
            map.put("errMsp","");
        }else{
            map.put("success",false);
            map.put("newsList",null);
            map.put("errMsp","userId为空");
        }
        return map;
    }
}
